import axios from 'axios'

export function request(option) {
  const instance = axios.create({
    baseURL: '/api',
    timeout: 5000
  })
  // 拦截器
  instance.interceptors.request.use(config => {
    return config
  }, err => {
    console.log('请求错误', err)
  })
  instance.interceptors.response.use(res => {
    return res.data
  }, err => {
    console.log('响应错误', err)
  })
  return instance(option)
}